﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;

namespace Sistema_de_Taller.SDT_DAL.Utilities
{
    public class Employee_DAL
    {
        public DataSet EmployeeLoad()
        {
            //EL @ es para dividir una línea de código en 2
            SqlConnection Connection = Common_Files.Connection.OpenConecction();
            SqlDataAdapter Command = new SqlDataAdapter(@"Select Employee_ID, Employee_Name as Name, Employee_Residence as Residence, Employee_Phone as Phone from Employee", Connection);
            DataSet DataSet = new DataSet();
            Command.Fill(DataSet);
            return (DataSet);
        }

        public void EmployeeInsert(Common_Files.Definitions.Employee Employee)
        {
            //EL @ es para dividir una línea de código en 2
            SqlConnection Connection = Common_Files.Connection.OpenConecction();
            SqlCommand Command = new SqlCommand(@"insert into Employee (Employee_Name, Employee_Residence, Employee_Phone) 
                                                                values ('" + Employee.Employee_Name + "', '" + Employee.Employee_Residence + "', '" + Employee.Employee_Phone + "')", Connection);
            Common_Files.Connection.CloseConecction(Connection, Command);
        }

        public void EmployeeUpdate(Common_Files.Definitions.Employee Employee)
        {
            SqlConnection Connection = Common_Files.Connection.OpenConecction();
            SqlCommand Command = new SqlCommand("update Employee set Employee_Name = '" + Employee.Employee_Name + "' , Employee_Residence = '" + Employee.Employee_Residence + "', Employee_Phone = '" + Employee.Employee_Phone + "' where Employee_ID = '" + Employee.Employee_ID + "'", Connection);
            Common_Files.Connection.CloseConecction(Connection, Command);
        }

    }
}